<template>
  <div class="customer-intention" >
    <el-form :model="custIntentionRule" label-width="120px" class="demo-ruleForm">

    <el-row class="row" v-if="flag">
      <affix
        :label="$t('configLazyLoad.customerIntention.intentionBtn')">
        <el-col>
          <el-form-item :label="cusIntentionRuleLabel" label-width="200px">
            <el-switch v-model="cusIntentionRuleEnable" @change="custIntentionChange">
            </el-switch>
          </el-form-item>
        </el-col>
      </affix>

      <el-col :span="15" class="left">
        <affix
          :label="$t('configLazyLoad.customerIntention.intentionType') + '['+ custAttrPer +'%]'">
          <el-row class="content-box">
            <el-col class="score" :span="11">
              <el-form-item :label="$t('configLazyLoad.customerIntention.newCustomer') + ':'">
                <el-input v-model.trim="custIntentionRule.newVisitor" :disabled="!cusIntentionRuleEnable" @change="computedData(custIntentionRule.newVisitor, 'newVisitor')" class="score-input">
                  <template slot="append">{{$t('configLazyLoad.customerIntention.score')}}</template>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col class="proportion" :span="10">
              <div class="blue" :style="'width:' + newVisitorPer + '%'"></div>
            </el-col>
            <el-col class="number" :span="2">{{newVisitorPer}}%</el-col>
          </el-row>
          <el-row class="content-box">
            <el-col class="score" :span="11">
              <el-form-item prop="addCustomer" :label="$t('configLazyLoad.customerIntention.addCustomer') + ':'">
              <el-input v-model.trim="custIntentionRule.addCustomer" :disabled="!cusIntentionRuleEnable"  @change="computedData(custIntentionRule.addCustomer, 'addCustomer')" class="score-input">
                <template slot="append">{{$t('configLazyLoad.customerIntention.score')}}</template>
              </el-input>
              </el-form-item>
            </el-col>
            <el-col class="proportion" :span="10">
              <div class="blue" :style="'width:' + addCustomerPer + '%'"></div>
            </el-col>
            <el-col class="number" :span="2">{{addCustomerPer}}%</el-col>
          </el-row>
          <el-row class="content-box">
            <el-col class="score" :span="11">
              <el-form-item prop="visitViewGT2To5" :label="$t('configLazyLoad.customerIntention.intention1') + ':'">
              <el-input v-model.trim="custIntentionRule.visitViewGT2To5" :disabled="!cusIntentionRuleEnable"  @change="computedData(custIntentionRule.visitViewGT2To5, 'visitViewGT2To5')" class="score-input">
                <template slot="append">{{$t('configLazyLoad.customerIntention.score')}}</template>
              </el-input>
              </el-form-item>
            </el-col>
            <el-col class="proportion" :span="10">
              <div class="blue" :style="'width:' + visitViewGT2To5Per + '%'"></div>
            </el-col>
            <el-col class="number" :span="2">{{visitViewGT2To5Per}}%</el-col>
          </el-row>
          <el-row class="content-box">
            <el-col class="score" :span="11">
              <el-form-item prop="visitViewGT5" :label="$t('configLazyLoad.customerIntention.intention2') + ':'">
              <el-input v-model.trim="custIntentionRule.visitViewGT5" :disabled="!cusIntentionRuleEnable"  @change="computedData(custIntentionRule.visitViewGT5, 'visitViewGT5')" class="score-input">
                <template slot="append">{{$t('configLazyLoad.qualityCheck.score')}}</template>
              </el-input>
              </el-form-item>
            </el-col>
            <el-col class="proportion" :span="10">
              <div class="blue" :style="'width:' + visitViewGT5Per + '%'"></div>
            </el-col>
            <el-col class="number" :span="2">{{visitViewGT5Per}}%</el-col>
          </el-row>
        </affix>
        <affix
          :label="$t('configLazyLoad.customerIntention.intention3') + '['+ custChannelPer+'%]'">
          <el-row class="content-box">
            <el-col class="score" :span="11">
              <el-form-item prop="searchEngine" :label="$t('report.imSearchEngine') + ':'">
              <el-input v-model.trim="custIntentionRule.searchEngine" :disabled="!cusIntentionRuleEnable" @change="computedData(custIntentionRule.searchEngine, 'searchEngine')" class="score-input">
                <template slot="append">{{$t('configLazyLoad.customerIntention.score')}}</template>
              </el-input>
              </el-form-item>
            </el-col>
            <el-col class="proportion" :span="10">
              <div class="blue" :style="'width:' + searchEnginePer + '%'"></div>
            </el-col>
            <el-col class="number" :span="2">{{searchEnginePer}}%</el-col>
          </el-row>
          <el-row class="content-box">
            <el-col class="score" :span="11">
              <el-form-item prop="pc" :label="$t('webchat.platformPc') + ':'">
              <el-input v-model.trim="custIntentionRule.pc" :disabled="!cusIntentionRuleEnable" @change="computedData(custIntentionRule.pc, 'pc')" class="score-input">
                <template slot="append">{{$t('configLazyLoad.customerIntention.score')}}</template>
              </el-input>
              </el-form-item>
            </el-col>
            <el-col class="proportion" :span="10">
              <div class="blue" :style="'width:' + pcPer + '%'"></div>
            </el-col>
            <el-col class="number" :span="2">{{pcPer}}%</el-col>
          </el-row>
          <el-row class="content-box">
            <el-col class="score" :span="11">
              <el-form-item prop="weixin" :label="$t('webchat.platformWeixin') + ':'">
              <el-input v-model.trim="custIntentionRule.weixin" :disabled="!cusIntentionRuleEnable" @change="computedData(custIntentionRule.weixin, 'weixin')" class="score-input">
                <template slot="append">{{$t('configLazyLoad.customerIntention.score')}}</template>
              </el-input>
              </el-form-item>
            </el-col>
            <el-col class="proportion" :span="10">
              <div class="blue" :style="'width:' + weixinPer + '%'"></div>
            </el-col>
            <el-col class="number" :span="2">{{weixinPer}}%</el-col>
          </el-row>
          <el-row class="content-box">
            <el-col class="score" :span="11">
              <el-form-item prop="wxmini" :label="$t('webchat.platformWeixinMini') + ':'">
                <el-input v-model.trim="custIntentionRule.wxmini" :disabled="!cusIntentionRuleEnable" @change="computedData(custIntentionRule.wxmini, 'wxmini')" class="score-input">
                  <template slot="append">{{$t('configLazyLoad.customerIntention.score')}}</template>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col class="proportion" :span="10">
              <div class="blue" :style="'width:' + wxminiPer + '%'"></div>
            </el-col>
            <el-col class="number" :span="2">{{wxminiPer}}%</el-col>
          </el-row>
          <el-row class="content-box">
            <el-col class="score" :span="11">
              <el-form-item prop="weibo" :label="$t('webchat.platformWeibo') + ':'">
              <el-input v-model.trim="custIntentionRule.weibo" :disabled="!cusIntentionRuleEnable" @change="computedData(custIntentionRule.weibo, 'weibo')" class="score-input">
                <template slot="append">{{$t('configLazyLoad.customerIntention.score')}}</template>
              </el-input>
              </el-form-item>
            </el-col>
            <el-col class="proportion" :span="10">
              <div class="blue" :style="'width:' + weiboPer + '%'"></div>
            </el-col>
            <el-col class="number" :span="2">{{weiboPer}}%</el-col>
          </el-row>
          <el-row class="content-box">
            <el-col class="score" :span="11">
              <el-form-item prop="wap" :label="$t('webchat.platformWap') + ':'">
                <el-input v-model.trim="custIntentionRule.wap" :disabled="!cusIntentionRuleEnable" @change="computedData(custIntentionRule.wap, 'wap')" class="score-input">
                  <template slot="append">{{$t('configLazyLoad.customerIntention.score')}}</template>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col class="proportion" :span="10">
              <div class="blue" :style="'width:' + wapPer + '%'"></div>
            </el-col>
            <el-col class="number" :span="2">{{wapPer}}%</el-col>
          </el-row>
          <el-row class="content-box">
            <el-col class="score" :span="11">
              <el-form-item prop="dy" :label="$t('webchat.platformTikTok') + ':'">
                <el-input v-model.trim="custIntentionRule.dy" :disabled="!cusIntentionRuleEnable" @change="computedData(custIntentionRule.dy, 'dy')" class="score-input">
                  <template slot="append">{{$t('configLazyLoad.customerIntention.score')}}</template>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col class="proportion" :span="10">
              <div class="blue" :style="'width:' + dyPer + '%'"></div>
            </el-col>
            <el-col class="number" :span="2">{{dyPer}}%</el-col>
          </el-row>
          <el-row class="content-box">
            <el-col class="score" :span="11">
              <el-form-item prop="wxkf" :label="$t('webchat.platformWXKF') + ':'">
                <el-input v-model.trim="custIntentionRule.wxkf" :disabled="!cusIntentionRuleEnable" @change="computedData(custIntentionRule.wxkf, 'wxkf')" class="score-input">
                  <template slot="append">{{$t('configLazyLoad.customerIntention.score')}}</template>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col class="proportion" :span="10">
              <div class="blue" :style="'width:' + wxkfPer + '%'"></div>
            </el-col>
            <el-col class="number" :span="2">{{wxkfPer}}%</el-col>
          </el-row>
          <el-row class="content-box">
            <el-col class="score" :span="11">
              <el-form-item prop="sdk" :label="$t('webchat.platformApp') + ':'">
              <el-input v-model.trim="custIntentionRule.sdk" :disabled="!cusIntentionRuleEnable" @change="computedData(custIntentionRule.sdk, 'sdk')" class="score-input">
                <template slot="append">{{$t('configLazyLoad.customerIntention.score')}}</template>
              </el-input>
              </el-form-item>
            </el-col>
            <el-col class="proportion" :span="10">
              <div class="blue" :style="'width:' + sdkPer + '%'"></div>
            </el-col>
            <el-col class="number" :span="2">{{sdkPer}}%</el-col>
          </el-row>
        </affix>
        <affix
          :label="$t('configLazyLoad.customerIntention.intention6') +'['+ custOptPer+'%]'">
          <el-row class="content-box">
            <el-col class="score" :span="11">
              <el-form-item prop="activeSession" :label="$t('configLazyLoad.customerIntention.intention4') + ':'">
              <el-input v-model.trim="custIntentionRule.activeSession" :disabled="!cusIntentionRuleEnable" @change="computedData(custIntentionRule.activeSession, 'activeSession')" class="score-input">
                <template slot="append">{{$t('configLazyLoad.customerIntention.score')}}</template>
              </el-input>
              </el-form-item>
            </el-col>
            <el-col class="proportion" :span="10">
              <div class="blue" :style="'width:' + activeSessionPer + '%'"></div>
            </el-col>
            <el-col class="number" :span="2">{{activeSessionPer}}%</el-col>
          </el-row>
          <el-row class="content-box">
            <el-col class="score" :span="11">
              <el-form-item prop="pageView" :label="$t('configLazyLoad.customerIntention.intention5') + ':'">
              <el-input v-model.trim="custIntentionRule.pageView" :disabled="!cusIntentionRuleEnable" @change="computedData(custIntentionRule.pageView, 'pageView')" class="score-input">
                <template slot="append">{{$t('configLazyLoad.customerIntention.score')}}</template>
              </el-input>
              </el-form-item>
            </el-col>
            <el-col class="proportion" :span="10">
              <div class="blue" :style="'width:' + pageViewPer + '%'"></div>
            </el-col>
            <el-col class="number" :span="2">{{pageViewPer}}%</el-col>
          </el-row>
          <el-row>
            <el-button :disabled="!cusIntentionRuleEnable" type="primary" class="primary_btn fr find" @click.stop="submit">{{$t('config.channel.saveSettings')}}</el-button>
          </el-row>
        </affix>
      </el-col>
      <el-col :span="9" class="right">
        <div class="tip-card">
          <span class="warn"><span>{{$t('configLazyLoad.customerIntention.tips')}}</span></span>
        </div>
        <div class="tip">
          <div class="title">{{$t('configLazyLoad.customerIntention.tips1')}}</div>
          <div class="content">{{$t('configLazyLoad.customerIntention.tips2')}}</div>
        </div>
        <div class="tip">
          <div class="title">{{$t('configLazyLoad.customerIntention.tips3')}}</div>
          <div class="content">{{$t('configLazyLoad.customerIntention.tips4')}}</div>
        </div>
        <div class="tip">
          <div class="title">{{$t('configLazyLoad.customerIntention.tips5')}}</div>
          <div class="content">{{$t('configLazyLoad.customerIntention.tips6')}}</div>
        </div>
      </el-col>
    </el-row>
    </el-form>
  </div>
</template>
<script>
  import Affix from '@/components/ui-modules/affix/Affix'
  import {checkform} from '@/utils/validate'
  import {deepClone} from '@/utils/m7Utils'
  export default {
    name: 'customerIntention',
    data () {
      return {
        flag: true,
        custAttrPer: '0.00',
        custChannelPer: '0.00',
        custOptPer: '0.00',
        newVisitorPer: '0.00',
        visitViewGT2To5Per: '0.00',
        addCustomerPer: '0.00',
        visitViewGT5Per: '0.00',
        searchEnginePer: '0.00',
        sdkPer: '0.00',
        wapPer: '0.00',
        weixinPer: '0.00',
        wxminiPer: '0.00',
        weiboPer: '0.00',
        dyPer: '0.00',
        wxkfPer: '0.00',
        pcPer: '0.00',
        activeSessionPer: '0.00',
        pageViewPer: '0.00',
        id: '',
        cusIntentionRuleEnable: false,
        cusIntentionRuleLabel: this.$t('configLazyLoad.customerIntention.IntentionClose') + ':',
        custIntentionRule: {
          newVisitor: 0,
          addCustomer: 0,
          visitViewGT2To5: 0,
          visitViewGT5: 0,
          searchEngine: 0,
          sdk: 0,
          wap: 0,
          weixin: 0,
          wxmini: 0,
          dy: 0,
          wxkf: 0,
          weibo: 0,
          pc: 0,
          activeSession: 0,
          pageView: 0,
          all: 0
        }
      }
    },
    computed: {
    },
    watch: {
    },
    components: {
      Affix
    },
    created () {
//      this.$router.push({ path: '/index/monitor/table' })
    },
    methods: {
      statisticsOptAttr () {
        if (!(this.custIntentionRule.all === '0') && !(this.custIntentionRule.all === 0) && !(this.custIntentionRule.all === '')) {
          let _attrCount = 0
          if (!(this.custIntentionRule.activeSession === 0 || this.custIntentionRule.activeSession === '0' || this.custIntentionRule.activeSession === '')) {
            _attrCount += parseFloat(this.custIntentionRule.activeSession)
          }
          if (!(this.custIntentionRule.pageView === 0 || this.custIntentionRule.pageView === '0' || this.custIntentionRule.pageView === '')) {
            _attrCount += parseFloat(this.custIntentionRule.pageView)
          }
          this.custOptPer = (_attrCount / this.custIntentionRule.all * 100).toFixed(2)
        } else {
          this.custOptPer = '0.00'
        }
      },
      statisticsChannAttr () {
        if (!(this.custIntentionRule.all === '0') && !(this.custIntentionRule.all === 0) && !(this.custIntentionRule.all === '')) {
          let _attrCount = 0
          if (!(this.custIntentionRule.searchEngine === 0 || this.custIntentionRule.searchEngine === '0' || this.custIntentionRule.searchEngine === '')) {
            _attrCount += parseFloat(this.custIntentionRule.searchEngine)
          }
          if (!(this.custIntentionRule.sdk === 0 || this.custIntentionRule.sdk === '0' || this.custIntentionRule.sdk === '')) {
            _attrCount += parseFloat(this.custIntentionRule.sdk)
          }
          if (!(this.custIntentionRule.wap === 0 || this.custIntentionRule.wap === '0' || this.custIntentionRule.wap === '')) {
            _attrCount += parseFloat(this.custIntentionRule.wap)
          }
          if (!(this.custIntentionRule.weixin === 0 || this.custIntentionRule.weixin === '0' || this.custIntentionRule.weixin === '')) {
            _attrCount += parseFloat(this.custIntentionRule.weixin)
          }
          if (!(this.custIntentionRule.wxmini === 0 || this.custIntentionRule.wxmini === '0' || this.custIntentionRule.wxmini === '')) {
            _attrCount += parseFloat(this.custIntentionRule.wxmini)
          }
          if (!(this.custIntentionRule.dy === 0 || this.custIntentionRule.dy === '0' || this.custIntentionRule.dy === '')) {
            _attrCount += parseFloat(this.custIntentionRule.dy)
          }
          if (!(this.custIntentionRule.wxkf === 0 || this.custIntentionRule.wxkf === '0' || this.custIntentionRule.wxkf === '')) {
            _attrCount += parseFloat(this.custIntentionRule.wxkf)
          }
          if (!(this.custIntentionRule.weibo === 0 || this.custIntentionRule.weibo === '0' || this.custIntentionRule.weibo === '')) {
            _attrCount += parseFloat(this.custIntentionRule.weibo)
          }
          if (!(this.custIntentionRule.pc === 0 || this.custIntentionRule.pc === '0' || this.custIntentionRule.pc === '')) {
            _attrCount += parseFloat(this.custIntentionRule.pc)
          }
          this.custChannelPer = (_attrCount / this.custIntentionRule.all * 100).toFixed(2)
        } else {
          this.custChannelPer = '0.00'
        }
      },
      statisticsAttr () {
        if (!(this.custIntentionRule.all === '0') && !(this.custIntentionRule.all === 0) && !(this.custIntentionRule.all === '')) {
          let _attrCount = 0
          if (!(this.custIntentionRule.addCustomer === 0 || this.custIntentionRule.addCustomer === '0' || this.custIntentionRule.addCustomer === '')) {
            _attrCount += parseFloat(this.custIntentionRule.addCustomer)
          }
          if (!(this.custIntentionRule.newVisitor === 0 || this.custIntentionRule.newVisitor === '0' || this.custIntentionRule.newVisitor === '')) {
            _attrCount += parseFloat(this.custIntentionRule.newVisitor)
          }
          if (!(this.custIntentionRule.visitViewGT2To5 === 0 || this.custIntentionRule.visitViewGT2To5 === '0' || this.custIntentionRule.visitViewGT2To5 === '')) {
            _attrCount += parseFloat(this.custIntentionRule.visitViewGT2To5)
          }
          if (!(this.custIntentionRule.visitViewGT5 === 0 || this.custIntentionRule.visitViewGT5 === '0' || this.custIntentionRule.visitViewGT5 === '')) {
            _attrCount += parseFloat(this.custIntentionRule.visitViewGT5)
          }
          this.custAttrPer = (_attrCount / this.custIntentionRule.all * 100).toFixed(2)
        } else {
          this.custAttrPer = '0.00'
        }
      },
      statistics () {
        this.custIntentionRule.all = 0
        let _count = 0
        for (let key in this.custIntentionRule) {
          if (!(this.custIntentionRule[key] === '0') && !(this.custIntentionRule[key] === 0) && !(this.custIntentionRule[key] === '')) {
            _count += parseFloat(this.custIntentionRule[key])
          }
        }
        this.custIntentionRule.all = _count
        console.log(typeof this.custIntentionRule.all)
      },
      subPer () {
        if (!(this.custIntentionRule.all === '0') && !(this.custIntentionRule.all === 0) && !(this.custIntentionRule.all === '')) {
          this.custIntentionRule.newVisitor !== '' ? this.newVisitorPer = (parseFloat(this.custIntentionRule.newVisitor) / this.custIntentionRule.all * 100).toFixed(2) : this.newVisitorPer = '0.00'
          this.custIntentionRule.addCustomer !== '' ? this.addCustomerPer = (parseFloat(this.custIntentionRule.addCustomer) / this.custIntentionRule.all * 100).toFixed(2) : this.addCustomerPer = '0.00'
          this.custIntentionRule.visitViewGT2To5 !== '' ? this.visitViewGT2To5Per = (parseFloat(this.custIntentionRule.visitViewGT2To5) / this.custIntentionRule.all * 100).toFixed(2) : this.visitViewGT2To5Per = '0.00'
          this.custIntentionRule.visitViewGT5 !== '' ? this.visitViewGT5Per = (parseFloat(this.custIntentionRule.visitViewGT5) / this.custIntentionRule.all * 100).toFixed(2) : this.visitViewGT5Per = '0.00'
          this.custIntentionRule.searchEngine !== '' ? this.searchEnginePer = (parseFloat(this.custIntentionRule.searchEngine) / this.custIntentionRule.all * 100).toFixed(2) : this.searchEnginePer = '0.00'
          this.custIntentionRule.weixin !== '' ? this.weixinPer = (parseFloat(this.custIntentionRule.weixin) / this.custIntentionRule.all * 100).toFixed(2) : this.weixinPer = '0.00'
          this.custIntentionRule.weixin !== '' ? this.wxminiPer = (parseFloat(this.custIntentionRule.wxmini) / this.custIntentionRule.all * 100).toFixed(2) : this.wxminiPer = '0.00'
          this.custIntentionRule.weibo !== '' ? this.weiboPer = (parseFloat(this.custIntentionRule.weibo) / this.custIntentionRule.all * 100).toFixed(2) : this.weiboPer = '0.00'
          this.custIntentionRule.pc !== '' ? this.pcPer = (parseFloat(this.custIntentionRule.pc) / this.custIntentionRule.all * 100).toFixed(2) : this.pcPer = '0.00'
          this.custIntentionRule.activeSession !== '' ? this.activeSessionPer = (parseFloat(this.custIntentionRule.activeSession) / this.custIntentionRule.all * 100).toFixed(2) : this.activeSessionPer = '0.00'
          this.custIntentionRule.pageView !== '' ? this.pageViewPer = (parseFloat(this.custIntentionRule.pageView) / this.custIntentionRule.all * 100).toFixed(2) : this.pageViewPer = '0.00'
          this.custIntentionRule.sdk !== '' ? this.sdkPer = (parseFloat(this.custIntentionRule.sdk) / this.custIntentionRule.all * 100).toFixed(2) : this.sdkPer = '0.00'
          this.custIntentionRule.wap !== '' ? this.wapPer = (parseFloat(this.custIntentionRule.wap) / this.custIntentionRule.all * 100).toFixed(2) : this.wapPer = '0.00'
          this.custIntentionRule.dy !== '' ? this.dyPer = (parseFloat(this.custIntentionRule.dy) / this.custIntentionRule.all * 100).toFixed(2) : this.dyPer = '0.00'
          this.custIntentionRule.wxkf !== '' ? this.wxkfPer = (parseFloat(this.custIntentionRule.wxkf) / this.custIntentionRule.all * 100).toFixed(2) : this.wxkf = '0.00'
        } else {
          this.$nextTick(() => {
            this.newVisitorPer = '0.00'
            this.addCustomerPer = '0.00'
            this.visitViewGT2To5Per = '0.00'
            this.visitViewGT5Per = '0.00'
            this.searchEnginePer = '0.00'
            this.weixinPer = '0.00'
            this.wxminiPer = '0.00'
            this.weiboPer = '0.00'
            this.pcPer = '0.00'
            this.activeSessionPer = '0.00'
            this.pageViewPer = '0.00'
            this.sdkPer = '0.00'
            this.dyPer = '0.00'
            this.wxkfPer = '0.00'
            this.wapPer = '0.00'
          })
        }
      },
      computedData (_data, key) {
        console.log(key)
        if (checkform(_data, 'Number3')) {
          this.$nextTick(() => {
//            setTimeout(function () {
            this.custIntentionRule[key] = 0
            this.statistics()
            this.statisticsAttr()
            this.statisticsChannAttr()
            this.statisticsOptAttr()
            this.subPer()
//            }, 200)
          })
        } else {
          this.statistics()
          this.statisticsAttr()
          this.statisticsChannAttr()
          this.statisticsOptAttr()
          this.subPer()
        }
      },
      submit () {
        let _obj = deepClone(this.custIntentionRule)
        let _custIntentionRule = {}
        for (let key in _obj) {
          if (_obj[key] !== '') {
            _obj[key] = parseInt(_obj[key])
          } else {
            _obj[key] = 0
          }
        }
        _custIntentionRule.custIntentionRule = _obj
        if (this.id !== '') {
          _custIntentionRule._id = this.id
        }
        console.log(_custIntentionRule)
        this.$store.dispatch('saveGlobalSet', _custIntentionRule).then((rep) => {
          if (rep && rep.success) {
            this.$message.success(this.$t('config.channel.configSuccess'))
          } else {
            this.$message.error(this.$t('qualityCheck.saveFali'))
          }
        })
      },
      custIntentionChange () {
        let custIntentionObj = {}
        custIntentionObj.cusIntentionRuleEnable = this.cusIntentionRuleEnable
        if (this.id !== '') {
          custIntentionObj._id = this.id
        }
        this.$store.dispatch('saveGlobalSet', custIntentionObj).then((rep) => {
          if (rep.success) {
            if (custIntentionObj.cusIntentionRuleEnable) {
              this.$message.success(this.$t('configLazyLoad.customerIntention.IntentionOpen'))
              this.cusIntentionRuleLabel = this.$t('configLazyLoad.customerIntention.IntentionOpen') + ':'
            } else {
              this.$message.success(this.$t('configLazyLoad.customerIntention.IntentionClose'))
              this.cusIntentionRuleLabel = this.$t('configLazyLoad.customerIntention.IntentionClose') + ':'
            }
          }
        })
      }
    },
    beforeMount () {
      this.$store.dispatch('getGlobalSetById', {}).then((resp) => {
        console.log(resp)
        if (resp && resp.success) {
          if (resp.row) {
            this.id = resp.row._id
            this.cusIntentionRuleEnable = resp.row.cusIntentionRuleEnable
            if (this.cusIntentionRuleEnable) {
              this.cusIntentionRuleLabel = this.$t('configLazyLoad.customerIntention.IntentionOpen') + ':'
            } else {
              this.cusIntentionRuleLabel = this.$t('configLazyLoad.customerIntention.IntentionClose') + ':'
            }
            if (resp.row.custIntentionRule) {
              this.allCount = resp.row.custIntentionRule.all
              let _obj = resp.row.custIntentionRule
              for (let i in _obj) {
                this.custIntentionRule[i] = _obj[i]
              }
              this.statisticsAttr()
              this.statisticsChannAttr()
              this.statisticsOptAttr()
              this.subPer()
            }
          }
        }
      })
    }
  }
</script>
<style lang="stylus" scoped>
  @import "../../../../../assets/common.styl"
  .customer-intention
    background #fff
    margin-left 15px
    font-size 12px
    margin-top 20px
    .row
      margin-bottom 30px
    .left
      padding-right 25px
      margin-top 15px
      border-right 1px solid #e6e6e6
      .content-box
        color $cf-gray1
        margin-bottom 15px
        clear both
        .title
          width 100px
          padding-top 5px
        .score
          padding-right 30px
        .proportion
          position: relative
          background-color: #f6f6f6
          border: 1px solid #ccc
          font-size: 13px
          height: 22px
          border-radius: 2px
          float: left
          margin-top: 8px
          margin-right 10px
          .blue
            position:relative;
            text-align:left;
            color:#ffffff;
            height:20px;
            background-color:#009fe0;
        .number
          margin-top 13px
    .right
      padding 0 15px 0px 0px
      .tip
        margin-bottom 20px
        padding-left 15px
        .title
          font-size 14px
          line-height 14px
          color $c-prompt
          font-weight 500
          margin-bottom 10px
        .content
           font-size 12px
           color $cf-gray2
      .tip-card
         width 200px
         margin-top 10px
         margin-bottom 30px
         .warn
           color #fff
           position: relative;
           background: #009fe3;
           height: 20px;
           text-align: left;
           display: inline-block;
           text-transform: uppercase;
           font-size: 16px;
           padding: 5px 15px 6px 15px;
         .warn:after
           border-width: 15px;
           border-style: solid;
           border-color: #009fe3 #fff #009fe3 #009fe3;
           height: 1px;
           right: -16px;
           bottom: 0;
           display: inline-block;
           position: absolute;
           content: "";
</style>
